﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using Umbraco.Forms.Data;

namespace ContourStrikesAgain.Controls
{
     [System.Web.UI.ValidationProperty("Value")]
    public class CompareTextBox : TextBox
    {
        private TextBox tb2;

        public CompareTextBox()
        {
            EnsureChildControls();

        }

        protected override void CreateChildControls()
        {
            

            tb2 = new TextBox();
            tb2.ID = "testing";


            this.Controls.Add(tb2);
        }
        public string SecondCaption { get; set; }

        public override void RenderControl(System.Web.UI.HtmlTextWriter writer)
        {
            writer.WriteLine("<div class='comparetextbox'>");

            writer.WriteLine("<div class='comparetextboxfirst'>");
            base.RenderControl(writer);
            writer.WriteLine("</div>");

            writer.WriteLine("<div class='secondtextboxfirst'>");

            writer.WriteLine(string.IsNullOrEmpty(SecondCaption) ? "" : "<span>" + DictionaryHelper.GetText(SecondCaption) + "</span>");

            tb2.ID = "test";

            tb2.RenderControl(writer);

            writer.WriteLine("</div>");

            writer.WriteLine("</div>");
        }


        public string Value
        {
            get
            {
                if (this.Text == HttpContext.Current.Request["test"])
                    return this.Text;
                else
                    return "";
            }
            set
            {
                this.Text = value;
            }

        }
    }
}